//
//  HWMyAmountViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/31.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWMyAmountViewController.h"

@interface HWMyAmountViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) UIView *hederView;
@property(strong,nonatomic) UIView *icoView;
@property(strong,nonatomic) UIImageView *touxiangImageView;
@property(strong,nonatomic) UILabel *mingchenglabel;
@property(strong,nonatomic) UILabel *zhanghuoyuLabel;
@property(strong,nonatomic) UILabel *tixiangLabel;
// 第二个View
@property(strong,nonatomic) UIView *dierge2View;
@property(strong,nonatomic) UILabel *tishuLabel;

// 第三个Uiview
@property(strong,nonatomic)UIView *disange3View;
@property(strong,nonatomic)NSArray *jingerArr;
@property(strong,nonatomic)UIButton *selelBut; // 记录选中
@property(strong,nonatomic)NSString *xuanzhongStr; // 记录选中金额
@property(strong,nonatomic)UITextField *jingeTextFeild;

// 第四个Uiview
@property(strong,nonatomic)UIView *disi4GeView;
@property(strong,nonatomic)UIButton *xuanzhongBut;
@property(strong,nonatomic) NSString *zhifuleixingTypStr;


@end

@implementation HWMyAmountViewController

-(UITableView *)mainaTableVie {

    if  (_mainaTableVie == nil) {

        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
       // _mainaTableVie.backgroundColor = RGB(241, 242, 244);
        
    }
    return   _mainaTableVie ;

}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
}




- (void)setupUI {
    
    self.navigationItem.title = @"我的金额";
    self.view.backgroundColor = [UIColor whiteColor];
    
     [self.view addSubview:self.mainaTableVie];
    
     [self addtabview];
    
    
    
}

// 添加
- (void)addtabview  {
    
    // 1.108 +40  2. 42  3.36+65*CFLScaleValue*2+12*2+40  4. 40+40+20+35
    
    self.hederView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 108+40+  42+ 36+65*CFLScaleValue*2+12*2+40+ 40+40+20+35)];
    self.mainaTableVie.tableHeaderView = self.hederView;
    
    UITapGestureRecognizer *tap1  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hederViewTap)];
    [self.hederView addGestureRecognizer:tap1];
    
    
    [self addicoView];
    [self adddiergeView];
    [self adddisangeViewcontroll];
    [self addDiSigGeView];
    
    
}

- (void)hederViewTap {
    
    DLog(@"ocuhovouhou");
    
    
    [self.hederView endEditing:YES];
    
    
}

//添加headerView
- (void)addicoView {
    
    self.icoView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 108+40)];
    self.icoView.backgroundColor = [UIColor whiteColor];
    [self.hederView addSubview:self.icoView];
    
     self.touxiangImageView = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-62)/2, 12, 62,62)];
    //    self.touxiangimageView.image = [UIImage imageNamed:@"personal_bg"];
      // self.touxiangimageView.backgroundColor = [UIColor redColor];
       self.touxiangImageView.image = [UIImage imageNamed:@"morenTuPenson_ico"];
       self.touxiangImageView.layer.cornerRadius  = 31;
       self.touxiangImageView.layer.masksToBounds = YES;
       self.touxiangImageView.userInteractionEnabled = YES;
       self.touxiangImageView.layer.borderWidth = 2;
       self.touxiangImageView.layer.borderColor = RGB(178, 208, 255).CGColor;
     [self.icoView addSubview: self.touxiangImageView];
    
    
    self.mingchenglabel  = [[UILabel alloc]initWithFrame:CGRectMake(0, self.touxiangImageView.bottom , kScreenW, 34)];
       self.mingchenglabel.text = @"CIRES";
       self.mingchenglabel.font = [UIFont systemFontOfSize:15];
       self.mingchenglabel.textColor = RGB(51, 51, 51);
    //   self.mingchenglabel.backgroundColor = [UIColor redColor];
    self.mingchenglabel.textAlignment =  NSTextAlignmentCenter;
    [self.icoView addSubview:self.mingchenglabel];
    
    
    UIView *huiseView = [[UIView alloc]initWithFrame:CGRectMake(15,self.mingchenglabel.bottom, kScreenW-15*2, 40)];
    huiseView.backgroundColor = RGB(233, 241, 255);
    huiseView.layer.cornerRadius = 6;
    huiseView.layer.masksToBounds = YES;
    [self.icoView addSubview:huiseView];
    
    
      self.zhanghuoyuLabel  = [[UILabel alloc]initWithFrame:CGRectMake(7, 0, 160, 40)];
        self.zhanghuoyuLabel.text = @"账户余额 :100.00";
        self.zhanghuoyuLabel.font = [UIFont systemFontOfSize:14];
        self.zhanghuoyuLabel.textColor = RGB(51, 51, 51);
     //   self.mingchenglabel.backgroundColor = [UIColor redColor];
     //self.zhanghuoyuLabel.textAlignment =  NSTextAlignmentCenter;
  
     NSMutableAttributedString *test =   [WMUtil attributedStringWithText:@"账户余额 ：100.00" withRangText:@"100.00" withColor: RGB(253, 178, 50) withFont: [UIFont systemFontOfSize:14]];
    
    self.zhanghuoyuLabel.attributedText =test;
    
     [huiseView addSubview:self.zhanghuoyuLabel];
    
    
    
        self.tixiangLabel  = [[UILabel alloc]initWithFrame:CGRectMake( kScreenW-15*2-7-160, 0, 160, 40)];
         // self.tixiangLabel.text = @"账户余额 :100.00";
          self.tixiangLabel.font = [UIFont systemFontOfSize:14];
          self.tixiangLabel.textColor = RGB(51, 51, 51);
       //   self.mingchenglabel.backgroundColor = [UIColor redColor];
       self.tixiangLabel.textAlignment =  NSTextAlignmentRight;
    
       NSMutableAttributedString *test1 =   [WMUtil attributedStringWithText:@"可提现余额 :100.00" withRangText:@"100.00" withColor: RGB(253, 178, 50) withFont: [UIFont systemFontOfSize:14]];
      
      self.tixiangLabel.attributedText =test1;
      
     [huiseView addSubview:self.tixiangLabel];
    
    
    
}

//第二个Uiview
- (void)adddiergeView {
    self.dierge2View = [[UIView alloc]initWithFrame:CGRectMake(0, self.icoView.bottom, kScreenW, 42)];
    self.dierge2View.backgroundColor = [UIColor whiteColor];
    [self.hederView addSubview:self.dierge2View];
    
    self.tishuLabel  = [[UILabel alloc]initWithFrame:CGRectMake(27, 8, kScreenW-54, 34)];
    self.tishuLabel.text = @"温馨提示：交易商品金额将自动进入账户，且进行冻结，无法提现，2天后自动解冻，方可体现";
    self.tishuLabel.font = [UIFont systemFontOfSize:12];
    //self.tishuLabel.textColor = RGB(51, 51, 51);
    self.tishuLabel.numberOfLines = 2;
    
    //   self.mingchenglabel.backgroundColor = [UIColor redColor];
  //   self.tishuLabel.textAlignment =  NSTextAlignmentCenter;
    [self.dierge2View addSubview:self.tishuLabel];
    
    
    
    
}


#pragma mark ------ 第三个UIview
- (void)adddisangeViewcontroll {
    
    self.disange3View = [[UIView alloc]initWithFrame:CGRectMake(0, self.dierge2View.bottom, kScreenW, 36+65*CFLScaleValue*2+12*2+40)];
  //  self.disange3View.backgroundColor = [UIColor redColor];
    [self.hederView addSubview:self.disange3View];
    
    UILabel   *xuanzeJingerLabel  = [[UILabel alloc]initWithFrame:CGRectMake(32, 0, kScreenW-32*2, 36)];
       xuanzeJingerLabel.text = @"请选择提现金额";
      xuanzeJingerLabel.font = [UIFont systemFontOfSize:14];
     xuanzeJingerLabel.textColor = RGB(51, 51, 51);
    //   self.mingchenglabel.backgroundColor = [UIColor redColor];
   // self.mingchenglabel.textAlignment =  NSTextAlignmentCenter;
    [self.disange3View addSubview:xuanzeJingerLabel];
    CGFloat kaudu = ((kScreenW-32*2)- (65*CFLScaleValue*3))/2;
     self.jingerArr  = @[@"5",@"10",@"50",@"100",@"500",@"1000"];
    
    for(int i = 0; i < self.jingerArr.count;i++) {
        
        int  line = i%3;
        int  shu = i/3;
        
        
        UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];
        but.frame = CGRectMake(32+line* 65*CFLScaleValue+kaudu*line, 36+shu*65*CFLScaleValue+shu*12, 65*CFLScaleValue, 65*CFLScaleValue);
        but.titleLabel.font = [UIFont systemFontOfSize:15];
        but.backgroundColor = RGB(233, 241, 255);
        [but setTitle:self.jingerArr[i] forState:UIControlStateNormal];
        [but setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal];
        but.layer.cornerRadius = 65*CFLScaleValue/2;
        but.layer.masksToBounds = YES;
        [but addTarget:self action:@selector(butTap:) forControlEvents:UIControlEventTouchUpInside];
        but.tag = i;
    
        [self.disange3View  addSubview:but];
        
        
        
    }
    
    UIView *huiseView = [[UIView alloc]initWithFrame:CGRectMake(15,36+65*CFLScaleValue*2+12*2, kScreenW-15*2, 40)];
     huiseView.backgroundColor = RGB(233, 241, 255);
     huiseView.layer.cornerRadius = 6;
     huiseView.layer.masksToBounds = YES;
    [self.disange3View addSubview:huiseView];
    
     UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(16, 0, 200, 40)];
    //textField.placeholder = @"请输入文字";
    textField.textColor = [UIColor redColor];
    
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"请输入自定义金额" attributes:@{NSForegroundColorAttributeName:RGB(102, 102, 102),
        NSFontAttributeName:textField.font
        }];
    textField.attributedPlaceholder = attrString;
    textField.font = [UIFont systemFontOfSize:14];
    textField.textColor = RGB(51, 51, 51);
    textField.text = @"";
    self.jingeTextFeild  = textField;
    textField.keyboardType = UIKeyboardTypeNumberPad;
    [huiseView addSubview:textField];
    
    
    
    
}


#pragma mark -------- 第四个UIview
- (void)addDiSigGeView {
    
    self.zhifuleixingTypStr = @"0";
    
    self.disi4GeView = [[UIView alloc]initWithFrame:CGRectMake(0,  self.disange3View.bottom, kScreenW, 40+40+20+35)];
  //  self.disi4GeView.backgroundColor = [UIColor redColor];
    [self.hederView addSubview: self.disi4GeView];
    
     UILabel    *withdrawalLabel = [[UILabel alloc]initWithFrame:CGRectMake(32, 4 , kScreenW-64, 36)];
     withdrawalLabel.text = @"请选择提现金额";
     withdrawalLabel.font = [UIFont systemFontOfSize:14];
     withdrawalLabel.textColor = RGB(51, 51, 51);
       //   self.mingchenglabel.backgroundColor = [UIColor redColor];
     withdrawalLabel.textAlignment =  NSTextAlignmentLeft;
    [self.disi4GeView addSubview:withdrawalLabel];
       
    CGFloat  w = (kScreenW-64)/2;
    NSArray *titleArr = @[@"支付宝",@"微信"];
    for (int i = 0; i < 2; i++) {
        
        UIButton *paymentTypebut = [UIButton buttonWithType:UIButtonTypeCustom];
        paymentTypebut.frame = CGRectMake(32+i*w, withdrawalLabel.bottom, w, 40);
        paymentTypebut.titleLabel.font = [UIFont systemFontOfSize:14];
        paymentTypebut.backgroundColor = RGB(255, 255, 255);
        
        
        [paymentTypebut setTitle:titleArr[i] forState:UIControlStateNormal];
        [paymentTypebut setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal];
        paymentTypebut.layer.borderColor = RGB(232, 232, 242).CGColor;
        paymentTypebut.layer.borderWidth = 0.5;
        
//        paymentTypebut.layer.cornerRadius = 65*CFLScaleValue/2;232
//        paymentTypebut.layer.masksToBounds = YES;
        [paymentTypebut addTarget:self action:@selector(paymentType:) forControlEvents:UIControlEventTouchUpInside];
        paymentTypebut.tag = i;
        if (i == 0) {
             paymentTypebut.layer.borderColor = RGB(26, 113, 255).CGColor;
              paymentTypebut.layer.borderWidth = 0.5;
            self.xuanzhongBut = paymentTypebut;
            
        }
        
        [self.disi4GeView  addSubview:paymentTypebut];
        
    }
    
    
    UIButton *tianxianTypebut = [UIButton buttonWithType:UIButtonTypeCustom];
    tianxianTypebut.frame = CGRectMake(65, 80+20, kScreenW-130, 35);
    tianxianTypebut.titleLabel.font = [UIFont systemFontOfSize:14];
    tianxianTypebut.backgroundColor = blueBackgroundBT;
    
    [tianxianTypebut setTitle:@"申请提现" forState:UIControlStateNormal];
    tianxianTypebut.layer.cornerRadius = 35/2;
    tianxianTypebut.layer.masksToBounds = YES;
    [tianxianTypebut addTarget:self action:@selector(tianxianTypebutTap) forControlEvents:UIControlEventTouchUpInside];
    
    [self.disi4GeView addSubview:tianxianTypebut];
    
    
//    paymentTypebut.layer.borderColor = RGB(232, 232, 242).CGColor;
//    paymentTypebut.layer.borderWidth = 0.5;
    

    
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return  0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    return  cell;
    
    
}




#pragma mark -------- 第三个
- (void)butTap:(UIButton *)sender {
    
    NSInteger tag = sender.tag;
    
    self.selelBut.backgroundColor = RGB(233, 241, 255);
    
    self.selelBut = sender;
    sender.backgroundColor =  RGB(140, 184, 255);
    
    self.xuanzhongStr =  self.jingerArr[tag];
    
    
    
    
    
}



#pragma mark ----------- 第四个UIview

- (void)paymentType:(UIButton *)sender {
    
    

     self.xuanzhongBut.layer.borderColor = RGB(232, 232, 242).CGColor;
     self.xuanzhongBut.layer.borderWidth = 0.5;
    
    self.xuanzhongBut = sender;
    
    sender.layer.borderColor = RGB(26, 113, 255).CGColor;
    sender.layer.borderWidth = 0.5;
    self.zhifuleixingTypStr = [NSString stringWithFormat:@"%ld",sender.tag];
    
    
     DLog(@"支付类型 %@", self.zhifuleixingTypStr);
    
    
    
    
    
}



- (void)tianxianTypebutTap {
    
    DLog(@"申请支付类型");
    
}





@end
